package Test03;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import lesson16.User;

public class LoginServerObject {
	
	public static void main(String[] args) {
		try {
			//创建ServerSocket对象
			ServerSocket serverSocket=new ServerSocket(8800);
			//监听有没有信息发送过来
			Socket socket=serverSocket.accept();
			//创建输入流
			InputStream is=socket.getInputStream();
			ObjectInputStream ois=new ObjectInputStream(is);
			User user=(User)ois.readObject();
			System.out.println("接收到的客户端登陆信息为:"+user.toString());
			
			//给客户端响应
			String reply="你好,我是否服务器,欢迎登陆!";
			OutputStream os=socket.getOutputStream();
			os.write(reply.getBytes());
			
			
			ois.close();
			is.close();
			os.close();
			socket.close();
			serverSocket.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
